package top.shen33.yang.services.impl;



import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.transaction.annotation.Transactional;
import top.shen33.yang.model.entity.RbacPermission;
import top.shen33.yang.mapper.RbacPermissionMapper;
import top.shen33.yang.services.RbacPermissionService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author oreilly
 * @since 2018-08-23
 */
@Service
public class RbacPermissionServiceImpl extends ServiceImpl<RbacPermissionMapper, RbacPermission>implements RbacPermissionService {


    @Override
    public Class clazz() {
        return RbacPermission.class;
    }

    @Override
    @Transactional
    public void doAdd(RbacPermission itemRbacPermission) {

        itemRbacPermission.insertOrUpdate();
    }

    @Override
    @Transactional
    public void doUpdate(RbacPermission itemRbacPermission) {

        itemRbacPermission.insertOrUpdate();
    }

    @Override
    @Transactional
    public void doDelete(String[] ids) {

        QueryWrapper<RbacPermission> ew = new QueryWrapper<>();
        ew.in("sid", ids);
        new RbacPermission().delete(ew);
    }


    @Override
    public List<RbacPermission> all(RbacPermission itemRbacPermission) {

        return this.baseMapper.all(itemRbacPermission);
    }

    @Override
    @Transactional
    public void doImport(List<RbacPermission> dataList) {

    }

    @Override
    public RbacPermission getOne(String id) {
        return getById(id);
    }


    @Override
    public Page<RbacPermission> pageInfo(Page page, RbacPermission itemRbacPermission) {

        List<RbacPermission> dataList = this.baseMapper.pageInfo(page, itemRbacPermission);
        page.setRecords(dataList);
        return page;
    }
        @Override
    public RbacPermission tree() {

        return this.baseMapper.tree();
    }

        @Override
    public List<RbacPermission> permissionList(String roleId) {

        return this.baseMapper.permissionList(roleId);
    }

}
